package day_2022_7_to_8.day48;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author haomin
 * @date 2022/08/08 15:21
 **/
public class Day24_1_Num761_MakeLargestSpecial {
    public static void main(String[] args) {
        makeLargestSpecial("11011000");
    }
    public static String makeLargestSpecial(String s) {
        String res="";
        int count=0,pre=0,n=s.length();
        if(n==0){return "";}
        List<String> list=new ArrayList<>();
        for(int i=0;i<n;i++){
            char c=s.charAt(i);
            if(c=='1'){count++;}
            else{
                count--;
                if(count==0){
                    list.add("1"+makeLargestSpecial(s.substring(pre+1,i))+"0");
                    pre=i+1;
                }
            }
        }
        System.out.println(list.size());
        Collections.sort(list);
        for(int i=list.size()-1;i>=0;i--){res+=list.get(i);}
        return res;
    }
}